package com.xyht.sca_s.student_manage_system.modules.stampRegistration.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.stampRegistration.entity.SmsStampRegistrationProcess;
import com.xyht.sca_s.student_manage_system.modules.stampRegistration.mapper.SmsStampRegistrationProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class StampProcessInit {

    @Autowired
    private SmsStampRegistrationProcessMapper smsStampRegistrationProcessMapper;

    private String[] departmentNameArray = {"部门负责人","分管院领导"};

    @Bean
    public void stampRegistrationProcessInit() {
        List<SmsStampRegistrationProcess> processList =
                smsStampRegistrationProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsStampRegistrationProcess addProcess =
                        new SmsStampRegistrationProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setProcessIsUse(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessIsApplicantEdit(false);
                addProcess.setProcessSort(sort++);
                smsStampRegistrationProcessMapper.insert(addProcess);
            }

        }
    }
}
